package com.xinkong.huangxunleiutils;

import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.xinkong.huangxunleiutils.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 黄训磊 on 2017/1/9 15:21
 */

public class LoginActivity extends BaseActivity {
    @BindView(R.id.webView_login)
    WebView mWebViewLogin;

    @Override
    public int getLayoutId() {
        return R.layout.activity_login;


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        ButterKnife.bind(this);
    }

    private void initView() {
        mWebViewLogin.loadUrl("http://121.43.153.202:8082/webapp/customer/login.html");
        mWebViewLogin.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)&&mWebViewLogin.canGoBack()){
            if (mWebViewLogin.getUrl().equals("http://s.click.taobao.com/RREMs4y")) {
                finish();
            } else {
                mWebViewLogin.goBack();
                return true;
            }

        }
        return false;
    }
}
